<?php
include_once 'model/contact/process.php';
include_once 'model/user/user_create.php';
$contact = new contact();
$user = new users();
$fillByName = $user->FillOneByName($_SESSION);
$result = $contact->FillAll();
$level_decode = json_decode($fillByName["level"], true);
?>
<div id="content">
    <h2 class="jquery_tab_title"><?php echo $phrase["manager_contact"] ?></h2>
    
    <?php if ($level_decode["admin"] != "" || $level_decode["create"] != "") { ?>
        <span class="bglink"><a class="link" href="<?= $url["home"] ?>/menu/contact-create"><?php echo $phrase["contact_create"] ?></a></span>
    <?php } ?>
        <span class="bglink"><a class="link" href="<?= $url["home"] ?>/menu/hotline-create"><?php echo $phrase["hotline_create"] ?></a></span>
    <table class="display" cellspacing="2" id="example">
        <thead>
            <tr>
                <th class="first" width="25%"><?php echo $phrase["contact_address"] ?></th>
                <th class="last" width="15%"><?php echo $phrase["contact_city"] ?></th>
                <th class="first" width="10%"><?php echo $phrase["contact_phone"] ?></th>
                <th class="last" width="15%"><?php echo $phrase["contact_telephone"] ?></th>
                <th class="first" width="20%"><?php echo $phrase["contact_email"] ?></th>
                <td class="status" width="8%"></td>
            </tr>
        </thead>
        <tbody>
            <?php
            while ($rows = mysql_fetch_array($result)) {
                $i++;
                ?>
                <?php if ($i % 2) { ?>
                    <tr class="gradeC odd">
                        <td><?php echo $rows["contact_address"] ?></td>
                        <td><?php echo $rows["contact_city"] ?></td>
                        <td><?php echo $rows["contact_phone"] ?></td>
                        <td><?php echo $rows["contact_telephone"] ?></td>
                        <td><?php echo $rows["contact_email"] ?></td>
                        <td class="first">
                            <?php if ($level_decode["admin"] != "" || $level_decode["update"] != "") { ?>
                                <a href="<?= $url["home"] ?>/menu/contactupdate/id/<?php echo $rows["contact_id"] ?>">
                                    <image src="<?= $url["home"] ?>/images/icons/edit-icon.gif"/>
                                </a>
                            <?php } ?>
                            <?php if ($level_decode["admin"] != "" || $level_decode["update"] != "" && $level_decode["delete"]) { ?>
                                | 
                            <?php } ?>
                            <?php if ($level_decode["admin"] != "" || $level_decode["delete"] != "") { ?>
                                <a href="<?= $url["home"] ?>/menu/contactdelete/id/<?php echo $rows["contact_id"] ?>" onclick="return confirm('Bạn có chắc chắn muốn xóa không.');">
                                    <image src="<?= $url["home"] ?>/images/icons/b_drop.png"/>
                                </a>
                            <?php } ?>
                        </td>
                    </tr>
                <?php } else { ?>
                    <tr class="gradeC even">
                        <td><?php echo $rows["contact_address"] ?></td>
                        <td><?php echo $rows["contact_city"] ?></td>
                        <td><?php echo $rows["contact_phone"] ?></td>
                        <td><?php echo $rows["contact_telephone"] ?></td>
                        <td><?php echo $rows["contact_email"] ?></td>
                        <td class="last">
                            <?php if ($level_decode["admin"] != "" || $level_decode["update"] != "") { ?>
                                <a href="<?= $url["home"] ?>/menu/contactupdate/id/<?php echo $rows["contact_id"] ?>">
                                    <image src="<?= $url["home"] ?>/images/icons/edit-icon.gif"/>
                                </a>
                            <?php } ?>
                            <?php if ($level_decode["admin"] != "" || $level_decode["update"] != "" && $level_decode["delete"]) { ?>
                                | 
                            <?php } ?>
                            <?php if ($level_decode["admin"] != "" || $level_decode["delete"] != "") { ?>
                                <a href="<?= $url["home"] ?>/menu/contactdelete/id/<?php echo $rows["contact_id"] ?>" onclick="return confirm('Bạn có chắc chắn muốn xóa không.');">
                                    <image src="<?= $url["home"] ?>/images/icons/b_drop.png"/>
                                </a>
                            <?php } ?>
                        </td>
                    </tr>
                <?php } ?>
            <?php } ?>
        </tbody>
        <tfoot>
            <tr>
                <th colspan="6"></th>
            </tr>
        </tfoot>
    </table>
</div>